// ==UserScript==
// @name         复制亚马逊评论
// @namespace    pacey
// @version      0.1
// @author       pacey
// @updateURL    https://gitee.com/great-pacey/tampermonkey/raw/master/copyAmazonReview.user.js
// @match        https://*.amazon.com/*
// @match        https://*.amazon.es/*
// @match        https://*.amazon.ru/*
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_setClipboard
// @grant unsafeWindow
// @grant GM_registerMenuCommand
// ==/UserScript==

(function() {
    'use strict';
    unsafeWindow.a = [];
    function loop(){
        unsafeWindow.a = unsafeWindow.a.concat([].slice.call(document.body.querySelectorAll('.review-text')).map(i=>i.innerText));
        var e = document.body.querySelector('.a-last a')
        if (e) {
            e.click();
            setTimeout(loop, 2000);
        } else {
            GM_setClipboard(unsafeWindow.a.join('\n'));
            alert('复制成功');
        }
    }
    GM_registerMenuCommand('copy', loop);
})();
